﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EditWidows/eYUITreeList.Master"
    AutoEventWireup="true" CodeBehind="SelfDefineTreeList.aspx.cs" Inherits="ZX.WebApp.SelfDefineTreeList" %>

<%@ Register Assembly="ZX.Web.UI.Controls" Namespace="ZX.Web.UI.Controls" TagPrefix="cc1" %>
<asp:Content ContentPlaceHolderID="headerPlace" runat="server">
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/reset-fonts-grids/reset-fonts-grids.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/menu/assets/skins/sam/menu.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/paginator/assets/skins/sam/paginator.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/treeview/assets/skins/sam/treeview.css" />
    <style type="text/css">
        .yui-skin-sam table {
	        width: 100%;
        }
        #tree {background: #fff; padding:1em;}
        #button-example-form fieldset, 
        #button-example-form fieldset div {
            border: 2px groove #ccc;
            margin: .5em;
            padding: .5em;

        }
        .yui-button#pushbutton2 button,
        .yui-button#pushbutton5 button, 
        .yui-button#pushbutton4 button,
        .yui-button .Add button {
            background: url(../button/assets/add.gif) center center no-repeat;
            text-indent: -4em;
            overflow: hidden;
            padding: 0 .75em;
            width: 2em;
            *margin-left: 4em;   /* IE only */
            *padding: 0 1.75em;  /* IE only */
        }  
        .yui-button#pushbutton3 button,
        .yui-button#pushbutton6 button, 
        .yui-button#pushbutton9 button {
            padding-left: 2em;
            background: url(../button/assets/add.gif) 10% 50% no-repeat; 
        }
            body
            {
                font:13px/1.231 arial,helvetica,clean,sans-serif;
                *font-size:small;
                *font:x-small; background: #eeeeee;
                text-align:center;
            }    
            a:link,a:visited{
                color:#1f376d;
            }
            a:hover{   color:#ff0000;
                text-decoration:underline;
            }  
            #fieldRight
            {
                height:99.5%;
            }
        <% =DataTableCss %>
    </style>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <script src="../Scripts/yui_2.9.0/build/dragdrop/dragdrop.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/calendar/calendar-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/treeview/treeview-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/resize/resize-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="按钮" ContentPlaceHolderID="HeaderControl" runat="server">
    <%= BtnItems %>
    <button type="button" id="btnFull" name="btnFull">
        全屏</button>
    <button type="button" id="btnReload" name="btnReload">
        刷新</button>
    <button type="button" id="btnClose" name="btnClose">
        关闭当前页</button>
    <!--  用于加载按钮事件 -->
    <script src="../Scripts/yui.list.YUITreeList.button.event.js" type="text/javascript"></script>
    <script src="../Scripts/yui.list.YUITreeList.Edit.list.common.js" type="text/javascript"></script>
    <script type="text/javascript">
    YAHOO.example.init = function () {
         function onButtonClick(p_oEvent) {
                 switch(this.get("id"))
                 {          
                     <% =InitBtnEvents %>
                    case "btnFull": 
                         fnFull();
                         break;
                    case "btnClose":
                         window.parent.$("#tabs").tabs('close','<% =PageTitle %>');
                         break;
                    case "btnReload":
                         fnReload();
                         break;
                    case "btnAreaUserSet":
                        fnAreaUserSet();
                        break;
                    default:
                         break;
                 }                        
        }
        YAHOO.util.Event.onContentReady("toolbar", function () {
        <% =BtnEvents  %>
          var btnAreaUserSet = new YAHOO.widget.Button("btnAreaUserSet");
            btnAreaUserSet.on("click", onButtonClick);
            var btns=document.getElementsByTagName("button");  
            if(const_entityName=="V_CrmCustomer"){
                document.getElementById("search").style.display="block";
                for(var i=0;i<btns.length;i++){
                   if(btns[i].id.indexOf("yui-gen")==-1){
                        btns[i].style.display="none";
                   }
                }
            }     
            if(const_entityName=="DatDepartment"){             
               for(var i=0;i<btns.length;i++){            
                   if(btns[i].id.indexOf("btnAreaUserSet")!=-1){
                        btns[i].style.display="block";
                   }
               }
            }
        var btnFull = new YAHOO.widget.Button("btnFull");
        btnFull.on("click", onButtonClick);
        var btnClose = new YAHOO.widget.Button("btnClose");
        btnClose.on("click", onButtonClick);
        var btnReload = new YAHOO.widget.Button("btnReload");
        btnReload.on("click", onButtonClick);
        });      
    } ();
    function AddButton() {
        var button = document.createElement('button');
        button.innerHTML = 'add tab';
        YAHOO.util.Event.on(button, 'click', addTab);
        tabView.appendChild(button);
    }
    </script>
</asp:Content>
<asp:Content ID="自定义树" ContentPlaceHolderID="leftPlaceHoder" runat="server">
    <!--用于搜索-->
    <script type="text/javascript">
        var serachDept = function () {
            var key = $("#txtdeptName").val();
            $("a").css("color", "")
            $("a:contains('" + key + "')").css("color", "red");
        }
    </script>
    <cc1:SelfDefineTree ID="treeDiv1" runat="server" TreeType="Course"></cc1:SelfDefineTree>
</asp:Content>
<asp:Content ID="列表及分页" ContentPlaceHolderID="DataPlaceHolder" runat="server">
    <div id="json">
    </div>
    <div id="bottom">
        <div id="pagetotal" style="float: left; height: 10px; padding: 8px; margin-top: 3px;
            width: 100px;"> 
        </div>
        <div id="page" style="float: left">
        </div>
    </div>
</asp:Content>
<asp:Content ID="脚本" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
    <!--  用于加载自定义脚本 -->
    <script src="../Scripts/appjs/model.<% =EntityName %>.js" type="text/javascript"></script>
    <script type="text/javascript">
    var PageTotal;
    var pageindex = 1;
    var ids = [];
    var pagesize = 25;
    var const_entityName="<%=EntityName%>",
        fkey="<%=Guid.Empty%>",
        hrCaption="",
        const_functionId   ="<% =FunctionID %>",//自定义条件
        const_EditEntity = "<% =EditEntity %>",//编辑实体名
        const_Order ="<% =Order %>",           //排序  
        const_UserId = "<% = UserId %>",       //
        const_DataFields = [<% =DataFields %>],
        const_DataColums = [<% =DataColums %>],
        const_EditWindowWidth = "<% =EditWindowWidth %>px",
		const_EditWindowHeight = "<% =EditWindowHeight %>px",
        const_CustomCondition = encodeURI("<% =DefineCondition %>"),//查询方案条件
        const_Condition =  encodeURI("<% =Condition %>"),//
        const_PageTitle=encodeURI("<% =PageTitle %>"),
        initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order="+const_Order+"&r="+Math.random()+"&zip=94089&results=10&output=json&functionid="+const_functionId+"&customCondition="+ const_CustomCondition+"&condition="+const_Condition,
        const_entityID = "<% =EntityId %>";  //实体ID名称
        //谈单老师总结 谈单老师能看到自己所谈的单
     
        if (const_functionId == '3d235d5d-7618-474b-919e-abcd0a80ea31')
            initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=(NegotiateTeach='" + const_UserId + "' or AddUser='" + const_UserId + "')";
        if(const_entityName=="V_CrmDeliverMajorStudent" || const_entityName=="V_CrmDeliverMajorProductLayout"
            || const_entityName=="V_CrmLiveOrDerManager") //课程排位初始化加载
            initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=(AddUser='00000000-0000-0000-0000-000000000000')";
    </script>
    <script src="../Scripts/Public.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/yui.list.YUITreeList1.js"></script>
    <script type="text/javascript">
        //改变节点处理函数
        function Native(caption, key) {
            //debugger
            fkey = key;
            hrCaption = caption;
            var conTemp = " DliverState<>'73DAC2CE-F4BF-403C-9ACC-D075551E3328'";
            if (const_functionId == '3d235d5d-7618-474b-919e-abcd0a80ea31')
                initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + window.encodeURI("<%=ForeignKey%>='" + fkey + "' and (NegotiateTeach='" + const_UserId + "' or AddUser='" + const_UserId + "')");
            else if (const_entityName == "V_CrmMajorStudentHr") {
                if (caption == "yearAll") {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + conTemp;
                }
                else if (caption == "year") {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + conTemp + " and " + window.encodeURI(" datepart(yy,starttime)=" + fkey);
                }
                else if (caption == "term") {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + conTemp + " and " + window.encodeURI(" termname='" + fkey + "'");
                } else {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + window.encodeURI(" datepart(yy,starttime)=" + caption + " and datepart(mm,starttime)=" + key + " and " + conTemp);
                }
            }
            else if (const_entityName == "V_bpm_OpenClassBudgetMaster") {
                if (caption == "yearAll") {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=";
                }
                else if (caption == "year") {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition="  + window.encodeURI(" datepart(yy,begindate)=" + fkey);
                }
                else if (caption == "term") {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + window.encodeURI(" txtProductLayoutID='" + fkey + "'");
                } else {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + window.encodeURI(" datepart(yy,begindate)=" + caption + " and datepart(mm,begindate)=" + key );
                }
            }
            else if (const_entityName == "V_CrmDeliverHrTerm" || const_entityName == "V_CrmDeliverHrClass") {
                if (caption == "yearAll") {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=";
                }
                else if (caption == "year") {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + window.encodeURI(" datepart(yy,starttime)=" + fkey);
                }
                else if (caption == "term") {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + window.encodeURI(" termname='" + fkey + "'");
                } else {
                    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + window.encodeURI(" datepart(yy,starttime)=" + caption + " and datepart(mm,starttime)=" + key);
                }
            }
            else {
                initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&condition=" + window.encodeURI("<%=ForeignKey%>='" + fkey + "'");
            }
            BindData();
            GetTotal("../Extend/AjaxData/JSONList.aspx?onlyTotal=true&" + initialRequestUrl);
            if (const_entityName == "V_CrmMajorStudentHr") {
                if (caption == "yearAll") {
                    const_CustomCondition = conTemp;
                }
                else if (caption == "year") {
                    const_CustomCondition = window.encodeURI(" datepart(yy,starttime)=" + fkey + " and " + conTemp);
                } else if (caption == "term") {
                    const_CustomCondition = window.encodeURI(" termname='" + fkey + "' and " + conTemp);
                }
                else {
                    const_CustomCondition = window.encodeURI(" datepart(yy,starttime)=" + caption + " and datepart(mm,starttime)=" + key + " and " + conTemp);
                }
            }
            else if (const_entityName == "V_bpm_OpenClassBudgetMaster") {
                if (caption == "yearAll") {
                    const_CustomCondition = conTemp;
                }
                else if (caption == "year") {
                    const_CustomCondition = window.encodeURI(" datepart(yy,begindate)=" + fkey );
                } else if (caption == "term") {
                    const_CustomCondition = window.encodeURI(" txtProductLayoutID='" + fkey +"'");
                }
                else {
                    const_CustomCondition = window.encodeURI(" datepart(yy,begindate)=" + caption + " and datepart(mm,begindate)=" + key );
                }
            }
            else if (const_entityName == "V_CrmDeliverHrTerm" || const_entityName == "V_CrmDeliverHrClass") {
                if (caption == "yearAll") {
                    
                }
                else if (caption == "year") {
                    const_CustomCondition = window.encodeURI(" datepart(yy,starttime)=" + fkey );
                } else if (caption == "term") {
                    const_CustomCondition = window.encodeURI(" termname='" + fkey );
                }
                else {
                    const_CustomCondition = window.encodeURI(" datepart(yy,starttime)=" + caption + " and datepart(mm,starttime)=" + key );
                }
            } else
                const_CustomCondition = window.decodeURI("<%=ForeignKey%>='" + fkey + "'");
        }
        (function () {
            var Dom = YAHOO.util.Dom,
            Event = YAHOO.util.Event;
            Event.onDOMReady(function () {
                var layout = new YAHOO.widget.Layout({
                    minWidth: 800,
                    minHeight: 500,
                    units: [
                    { position: 'left', width: 215, maxWidth: 300, body: 'left', gutter: '1px 0px',
                        collapseSize: 23, scroll: true, collapse: true, resize: true
                    },
                    { position: 'center', minWidth: 400, minHeight: 200, scroll: true }
                ]
                });
                layout.on('render', function () {
                    var el = layout.getUnitByPosition('center').get('wrap');
                    var layout2 = new YAHOO.widget.Layout(el, {
                        parent: layout,
                        minWidth: 400,
                        minHeight: 200,
                        units: [
                        { position: 'top', body: 'toolbar', height: 35, gutter: '1px', maxHeight: 80 },
                        { position: 'bottom', height: 35, body: 'bottom', gutter: '1 1' },
                        { position: 'center', body: 'data', gutter: '1px', scroll: true }
                    ]
                    });
                    layout2.render();
                });
                layout.render();
                InitLeftData();
            });
            function InitLeftData() {
                tree1 = new YAHOO.widget.TreeView("treeDiv1");
                tree1.setNodesProperty('propagateHighlightUp', true);
                tree1.setNodesProperty('propagateHighlightDown', true);
                tree1.render();
                tree1._nodes[1].expand();
                BindData();
            }
        })();    
    </script>
    <!-- 定义数据格式化方法 -->
    <script src="../Scripts/yui.list.dataformat.js" type="text/javascript"></script>
</asp:Content>
